package com.baidu.reflect;

import java.lang.reflect.Method;
import java.util.ArrayList;

public class D01_ClassDemo1 {
    public static void main(String[] args) throws Exception {
        ArrayList<Integer> list = new ArrayList<>();

        list.add(1);

        Class listClass = list.getClass();
        Method method = listClass.getDeclaredMethod("add", Object.class);
        method.setAccessible(true);

        Boolean invokeRet = (Boolean) method.invoke(list, "袁峰");

        System.out.println(invokeRet);
        System.out.println(list);

    }
}
